<!-- 个人中心 -->
<template>
	<view>
		<view class="up">
			<figure>
				<image src="../../static/imgs/coffee-logo.jpeg" mode="scaleToFill"></image>
			</figure>
			<text> 登录账号： {{userName}}</text>
		</view>
		<view class="down">
			<button type="warn" @click="quitAccount">安全退出</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName: uni.getStorageSync("account")
			}
		},
		methods: {
			// 退出账号
			quitAccount() {
				uni.showModal({
					content: '是否要退出登录',
					success: (res) => {
						if (res.confirm) {
							uni.showToast({
								title: "退出登录成功",
								icon: 'none'
							})
							uni.removeStorageSync('password');
							uni.removeStorageSync('account');
							uni.removeStorageSync('token');
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}, 1300)
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.up {
		display: flex;
		align-items: center;

		image {
			width: 200rpx;
			height: 200rpx;
		}
	}

	.down {
		button {
			width: 90%;
		}
	}
</style>
